//
//  Gameover.m
//  game
//
//  Created by 정수 최 on 12. 10. 31..
//  Copyright 2012년 __MyCompanyName__. All rights reserved.
//

#import "Gameover.h"


@implementation Gameover


+(CCScene *) scene
{    
	// 'scene' is an autorelease object.
	CCScene *scene = [CCScene node];
	
	// 'layer' is an autorelease object.
	Gameover *layer = [Gameover node];
	
	// add layer as a child to scene
	[scene addChild: layer];
	
	// return the scene
	return scene;
}

// on "init" you need to initialize your instance
-(id) init
{
	// always call "super" init
	// Apple recommends to re-assign "self" with the "super" return value
	if( (self=[super init])) {
		
		// create and initialize a Label
		CCLabelTTF *label = [CCLabelTTF labelWithString:@"Game over" fontName:@"Marker Felt" fontSize:64];
        
		// ask director the the window size
		CGSize size = [[CCDirector sharedDirector] winSize];
        
		// position the label on the center of the screen
		label.position =  ccp( size.width /2 , size.height/2+40 );
        
        
        CCMenuItem *restart = [CCMenuItemImage itemFromNormalImage:@"btn-play-normal.png" selectedImage:@"btn-play-selected.png" target:self selector:@selector(menuTouch:)];
        CCMenuItem *main2 = [CCMenuItemImage itemFromNormalImage:@"btn-highscores-normal.png" selectedImage:@"btn-highscores-selected.png" target:self selector:@selector(menuTouch:)];
        
        CCMenu *menu2 = [CCMenu menuWithItems:restart,main2, nil];
        menu2.position = ccp(240, 120);
        [menu2 alignItemsHorizontally];
        
        [self addChild:menu2];
        
        restart.tag = 1;
        main2.tag = 2;
        
		
		// add the label as a child to this Layer
		[self addChild: label];
	}
	return self;
}


- (void) menuTouch: (id)sender{
    CCMenuItem *tmenu = (CCMenuItem *)sender;
    
    if (tmenu.tag == 1) {
        CCScene *gorestart = [CCTransitionFade transitionWithDuration:2 scene:[playPage scene]];
        [[CCDirector sharedDirector] replaceScene:gorestart];
    } else if (tmenu.tag == 2) {
        CCScene *gomain2 = [CCTransitionFade transitionWithDuration:2 scene:[menuPage scene]];
        [[CCDirector sharedDirector] replaceScene:gomain2];
    }
    
}



// on "dealloc" you need to release all your retained objects
- (void) dealloc
{
	// in case you have something to dealloc, do it in this method
	// in this particular example nothing needs to be released.
	// cocos2d will automatically release all the children (Label)
	
	// don't forget to call "super dealloc"
	[super dealloc];
    
}


@end
